<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('人员资产列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list" >
                    <ul>
                        <li style="display: none;">
                            <label>人员编号：</label>
                            <input name="userId" th:value="${userid}" type="text"/>
                        </li>
                        <li>
                            <label>资产编号：</label>
                            <input type="text" name="assetsId"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()">
                <i class="fa fa-plus"></i> 领用新的资产
            </a>
            <a class="btn btn-primary" onclick="$.operate.adddetail()">
                <i class="fa fa-edit"></i> 借用新的资产
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('assets:presion:edit')}]];
    var removeFlag = [[${@permission.hasPermi('assets:presion:remove')}]];
    var prefix = ctx + "assets/presion";
    var assetsTypeDatas = [[${@dict.getType('assets_type')}]];
    var userid = [[${userid}]];

    function gobake(id) {

        $.modal.confirm("确认要归还选中的资产吗?", function() {
            var url = table.options.removeUrl;
            var data = { "ids": id };
            $.operate.submit(url, "post", "json", data);
//            $.modal.close();
        });
    }

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: ctx + "assets/receive/add/"+userid,
            detailUrl: ctx + "assets/borrow/add/"+userid,
            removeUrl: ctx + "assets/back/goback",
            exportUrl: prefix + "/export",
            modalName: "人员资产",
            sortName: "createTime",
            sortOrder: "desc",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '资产编号',
                    visible: true
                },
                {
                    field: 'assetsName',
                    title: '资产名称'
                },
                {
                    field: 'assetsType',
                    title: '资产类别',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(assetsTypeDatas, value);
                    }
                },
                {
                    field: 'assetsModel',
                    title: '规格型号'
                },
                {
                    field: 'assetsSn',
                    title: 'SN号'
                },
                {
                    field: 'createTime',
                    title: '领用时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="gobake((\'' + row.id + '\'))"><i class="fa fa-remove"></i>立即归还</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>